from typing import List


def calPoints(operations: List[str]) -> int:
    ans = 0
    arr = []
    for op in operations:
        if op == '+':
            pt = arr[-1]+arr[-2]
        elif op =='D':
            pt = arr[-1] * 2
        elif op =='C':
            ans -= arr.pop()
            continue
        else:
            pt = int(op)
        ans += pt
        arr.append(pt)
    return ans